package com.example.mapper.pc;

import com.example.entity.dto.pc.JHDCFXlistDto;
import com.example.entity.dto.pc.JHDCFXlistItem;
import com.example.entity.dto.pc.ListDto;
import com.example.entity.vo.pc.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface WLPHZBMapper {


    List<JHDCFXlistItem> JHDCFXlistItem(@Param("params") List<String> params,
                                        @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<JHDCFXlistVo> JHDCFXlist(JHDCFXlistDto dto);

    List<ItemVo> list(ListDto dto);

    List<String> V_XQRQ(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd);

    List<V_WLZXQ> V_WLZXQ(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd);

    @Select("SELECT (CASE WHEN TA027 != '' THEN TA027 ELSE TA033 END) orderNo, TA001 workSingle, TA002 workNo, TA006 productId, TA034 productName, TA035 specification, TA009 startTime,\n" +
            "            TA015 estimatedProduction,TA017 inventoryNumber,TA015-TA017 noEnterNumber, ISNULL(MD002,MA002) workCenter \n" +
            "            FROM MOCTA LEFT JOIN CMSMD ON MD001 = TA021  LEFT JOIN PURMA ON TA032=MA001\n" +
            "            WHERE TA011 != 'y' AND TA011 != 'Y' AND TA013 =  'Y' AND TA006 = #{productId}")
    List<GongDan> MOCTA(String productId);

    @Select("SELECT RTRIM(TC012) orderNo,XQL reqNums,DB single,DH No,ISNULL(TA006,ID) productId," +
            "ISNULL(TA034,MB002) productName,ISNULL(TA035,MB003) specification " +
            "FROM WLXQ LEFT JOIN MOCTA ON TA001=DB AND TA002=DH " +
            "WHERE LB='需求' AND ID= #{productId} AND XQRQ= #{date}\n")
    List<XQLVo> XQL(String productId, String date);

    @Select("SELECT RTRIM(TD021) orderNo,RTRIM(MA002) supplier,TD004 productId,TD005 productName,TD006 specification,TD008 orderNums,TD015 deliveredNums,TD008-TD015 undeliveredNums," +
            "TD012 estimatedDeliveryDate,TD007 warehouseId,RTRIM(MC002) warehouseName,TD014 remark,TD001 purchaseSingle,TD002 purchaseNo,TD003 purchaseXH,TC003 purchaseDate " +
            "FROM PURTD LEFT JOIN PURTC ON TD001=TC001 AND TD002=TC002 LEFT JOIN CMSMC ON TD007=MC001 LEFT JOIN PURMA ON TC004=MA001 " +
            "WHERE TD016='N' AND TD004=#{productId} AND TD018='Y' ORDER BY TC004,TD012")
    List<YGWHL> purchasedNoReturnNums(String productId);

    // (B.MC005 = 'Y') AND
    @Select("SELECT A.MC001 productId, B.MC002 warehouseName,A.MC007 AS inventory " +
            "FROM INVMC AS A LEFT JOIN CMSMC AS B ON A.MC002 = B.MC001 " +
            "WHERE A.MC001= #{productId} AND A.MC007 > 0")
    List<ZKC> totalInventoryNums(String productId);

    @Select("SELECT A.MC001 productId, B.MC002 warehouseName,A.MC007 AS inventory " +
            "FROM openrowset( 'SQLOLEDB', '192.168.8.10'; 'sa'; '',erp3_help.dbo.INVMC) A LEFT JOIN CMSMC AS B ON A.MC002 = B.MC001 " +
            "WHERE A.MC001= #{productId} AND A.MC007 > 0 AND B.MC005 = 'Y'")
    List<ZKC> totalInventoryNumsHzView(String productId);

    @Select("SELECT XQRQ reqDate, XQL reqNums, TC012 orderNo, DB reqSingle, DH reqNO FROM WLXQ WHERE LB = '需求' AND ID = #{productId} ORDER BY XQRQ ")
    List<ZXQneed> need(String productId);

    List<ItemVo> listHz(ListDto dto);

    List<ItemVo> listHzFaster(ListDto dto);

    List<ViewReplaceItemVo> viewReplaceItemVo(@Param("list") List<String> list);

    List<String> replaceItem(@Param("productId") String productId);
}
